package com.chinaisafe.user.vo.request;

import com.chinaisafe.base.common.vo.request.PageReqVo;
import com.chinaisafe.base.common.validated.AddGroup;
import com.chinaisafe.base.common.validated.QueryGroup;
import com.chinaisafe.base.common.validated.UpdateGroup;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import java.time.LocalDate;
import java.time.LocalDateTime;
import com.chinaisafe.user.entity.SysApp;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.Null;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;

/**
 * SysAppReqVO
 * Description：应用请求值对象
 *
 * @author tby
 * @date  2024-07-11 17:32:41
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@Schema(name = "SysAppReqVO", description = "应用请求值对象")
public class SysAppReqVO extends PageReqVo implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键id")
    @NotNull(groups = UpdateGroup.class, message = "主键id不能为空" )
    private Long id;

    @Schema(description = "乐观锁版本")
    private Integer version;

    @Schema(description = "名称")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class}, message = "名称不能为空" )
    private String name;

    @Schema(description = "应用端,WEB:web端应用,APP:app端应用,MINI_APP:小程序")
    @NotBlank(groups = {AddGroup.class, UpdateGroup.class}, message = "应用端不能为空" )
    private String clientType;

    @Schema(description = "应用分类:内部,外部")
    @NotBlank(groups = {UpdateGroup.class,AddGroup.class}, message = "应用分类" )
    private String type;

    @Schema(description = "应用版本")
    private String appVersion;

    @Schema(description = "应用logo")
    private String logo;

    @Schema(description = "应用简介")
    private String summary;

    @Schema(description = "排序")
    private Integer seq;

    @Schema(description = "是否启用")
    private Boolean enable;


    /**
     * 将请求值对象装换为实体
     * @return SysApp
     * @author tby
     * @date 2024-07-11 17:32:41
     */
    public SysApp convertToEntity() {
        SysApp entity = new SysApp();
        entity.setId(this.id);
        entity.setVersion(this.version);
        // 给实体对应的字段赋值 可根据实际业务删减
        entity.setName(this.name);
        entity.setClientType(this.clientType);
        entity.setType(this.type);
        entity.setAppVersion(this.appVersion);
        entity.setLogo(this.logo);
        entity.setSummary(this.summary);
        entity.setSeq(this.seq);
        entity.setEnable(this.enable);
        return entity;
    }
}
